Unity is a game engine developed by Unity Technologies
The application has many uses from building games and creating virtual environment
Unity supports many different platforms like: PC, Mac, Linux, Android, iOS, PS4, Xbox One, Wii U, Webgl and more
Why Unity? Low Barriers to Entry
There's a lare community marketplace
with lots of cool free assets
and lots of high quality assets
It's built on familiar languages
UnitScript (Javascript)
C#
Huge Development Library
Physics
Networking
UI
Audio
Comes with Free Dev Tools
Screen Shot 2016-03-05 at 1.22.02 PM.png
MonoDevelop: Built-In Code Editor for Unity
Unity comes with a code editor called MonoDevelop that syncs with your projects
This means you can launch MonoDevelop independently of your Unity application, but not have to worry about updating/syncing anything
If you prefer another code editor you can configure Unity to launch that, instead of MonoDevelop (Visual Studios)
MonoDev_StartUp.png
Visual Studio Community 2015
Cost of Unity
Free personal edition and pricey professional edition
Current licensing rate for indie devleopers or small studios is $75/month
Source code available for undisclosed price
Professional edition offers discounts in marketplace, analytic tools and team licensing
Building a VIrtual Environment
Unity can be used to build both 2D and 3D environments
3D games built on X, Y, Z coordinate system
Z+ being forward, X+ to the right and Y+ up
Scenes
Scenes contain the objects of your game
Can be anything from a menu to a level in your game
We build our game environments in scenes
GameObjects
Every object in your game is a gameobject
Can be anything from a building, to individual walls, crates, barrels, camera, trees and even the player itself
Each object has special properties like its position, scale, texture, and more
we call these properties components
Components
Components are functional pieces of a gameobject
Components contain key information like Transform, meshes, physics, scripts, audio, network, etc.
List of active components of a gameobject
Prefabs
Users store gameobject with all of its components into prefabs (prefabricated object)
Contributes to convenience and reusability of a project
Unity UI
Important Unity Dev Classes
MonoBehaviour
standard functions and events that get triggered during gameplay interaction
Transform
information regarding position, rotation, and scale, for a given game object
provides the necessary functions to manipulate that information
RigidBody
provides properties and functions that handle velocity, force, ass, torque, collision, and other physics-related stuff
MonoBehaviour
is the base class that every script in Unity derives from. By inheriting the behavior of this class, the scripts that the developer creates can access the "inner workings" of Unity
Update - the function that handles the frame update of the script/object
often used for movement, triggering events, and responding to input
relies on connections and variables that are created in Start function
Start - the function that is calledbefore Update is called for first time
used for initialization of variables within the script
Ex_C#_Script.png
Transform
Everyobject in a scene has a Transform
used to store and manipulate the position, rotation and scale of the object
Every Transform can have a parent, which allows you to apply position, rotation and scale hierarchically
Screen Shot 2016-03-07 at 8.22.57 PM.png
RigidBody
Adding a RIgidBody component to an object will put its motion under the control of Unity's physics engine
The RigidBody class lets you apply forces to the object and control it in a physically realistic way
Networking
Interpolation
Client-side prediction
De-Sync
Lockstep
Client-Authoritative
Local player, client, server, and host
Built-in Pieces
Network Manager allows you to easily configure the server and networking aspects of your game
Online/Offline scene
IP/Port
Player Spawning
Spawnable Prefabs
Network Behavior
Extends MonoBehaviour, and must be used whenever you need to work with networking within the script
Creating objects
Moving objects
Producing changes to the world
Enables:
Client/server checks
running code only on the client or servers
Client/Server Communication
SyncVar: Change on server -> update clients
Command: Run this code only on server
ClientCallback: Run t his code only on client
Spawning:
instantiating an object onlycreatese the object in the "local" world
must use NetworkServer.Spawn to put the bullet on server/clients
Common Pitfalls
Cameras
should only be one active camera at a time
multiplayer can mess this up
Control Scripts
Remote clients will still receive local input if the script is active
Audio Listener
You only want one of these active - local player most likely
Pitfalls Filled In
Camera:
Deactivate scene-wide
activate the local player's camera
Control Scripts:
Enable if local player, deactivate otherwise
AudioListener:
Enable if local player, deactivate otherwise
What's Missing?
General Opinion: Built-In options are not suitable for games with a large number of players
Hard to control the built-in components, generally just write your own
Physics:
Networking physics is a nightmare
Requires Client-Side tracking of the last ~2 seconds of past states and input
Client-SIde prediction cannot predict movement accurately because of non-deterministic physics -> noticeable inaccuracies in all but the best of systems
Server authoritative system can cause huge amounts of recalculation
Very nuanced and susceptible to bugs
Future Implementations
Chat Box
Being able to have scrollable chat box on the bottom of the screen that all players can communicate with within the server
Plenty of legally usable code on line to create, the GUI and communication between different players
Login Menu
Creating a login menu, probably storing different accounts with username and passwords in a database
Unity vs. Unreal
Quicker start up compared to Unreal
Quicker to set a prototype
Once you start stretching limits you hit walls on Unity (physics, networking)
Some people make Unity then port it into Unreal
Unity's animation system is much easier to use than Unreal
Table of Contents
Introduction
Why Unity? Low Barriers to Entry
MonoDevelop: Built-In Code Editor for Unity
Visual Studio Community 2015
Cost of Unity
Building a VIrtual Environment
Scenes
GameObjects
Components
Prefabs
Unity UI
Important Unity Dev Classes
MonoBehaviour
Transform
RigidBody
Networking
Built-in Pieces
Network Behavior
Extends MonoBehaviour, and must be used whenever you need to work with networking within the script
Enables:
Client/Server Communication
SyncVar: Change on server -> update clients
Command: Run this code only on server
ClientCallback: Run t his code only on client
Spawning:
Common Pitfalls
Cameras
Control Scripts
Audio Listener
Pitfalls Filled In
Camera:
Control Scripts:
AudioListener:
What's Missing?
General Opinion: Built-In options are not suitable for games with a large number of players
Physics:
Future Implementations
Chat Box
Login Menu
Unity vs. Unreal